/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
#include "信息条.h"



static void on_信息条绘制(C_Widget* self, S_2D画布* 画布) {
	C_信息条* box = static_cast<C_信息条*>(self);

	box->m_背景绘制.m_属性 = f_vg_gen属性(画布);
	S_凸边图元 图元 = {};
	图元.属性 = f_vg_get属性指针(画布, box->m_背景绘制.m_属性);
	box->m_背景绘制.f_Draw(画布, 图元, E_笔刷类型::e_单色填充);

	box->m_画心绘制.f_Draw(画布, box->m_背景绘制.m_属性, box->m_画心纹理);


	图元 = {};
	图元.属性 = f_vg_get属性指针(画布, box->m_背景绘制.m_属性);
	box->m_印章绘制.f_Draw(画布, 图元, E_笔刷类型::e_单色描边);

	auto& 字体 = f_surface_get字体(*self->m_UIctx, "鸿雷板书简体");
	box->m_文本绘制.f_Draw(画布, &字体, box->m_背景绘制.m_属性);

}

static void on_信息条布局(C_Widget* self, C_Widget** w, uint32 num) {
	if (!num) return;

	C_信息条* box = dynamic_cast<C_信息条*>(self);

	w[0]->f_setPos({ 10, self->m_Size.y - 100 });
	w[0]->f_setSize({ 20, 100 });

	w[1]->f_setPos({ 30, self->m_Size.y - 100 });
	w[1]->f_setSize({ 20, 100 });

	w[2]->f_setPos({ 80, self->m_Size.y - 100 });
	w[2]->f_setSize({ 20, 100 });

	w[3]->f_setPos({ 100, self->m_Size.y - 100 });
	w[3]->f_setSize({ 20, 100 });

	vec2 位置 = { 20, self->m_Size.y * 0.5f };
	box->m_捐款按钮_B站->f_setPos(位置);
	box->m_捐款按钮_B站->f_setSize({ 20, 60 });

	位置.y += 70;
	box->m_捐款按钮_爱发电->f_setPos(位置);
	box->m_捐款按钮_爱发电->f_setSize({ 20, 50 });

	//位置.x += 80;
	uint32 最近文件数量 = num - 4;
	位置.x = self->m_Size.x - 40 - 最近文件数量 * 25;
	位置.y = self->m_Size.y * 0.4;
	box->m_教程视频_B站->f_setPos(位置);
	box->m_教程视频_B站->f_setSize({ 20, 100 });

	位置.x -= 25;
	box->m_教程视频_Youtube->f_setPos(位置);
	box->m_教程视频_Youtube->f_setSize({ 20, 100 });


	位置.x = self->m_Size.x - 40;
	位置.y = 30;
	for (uint32 i = 4; i < num; ++i) {
		w[i]->f_setPos(位置);
		w[i]->f_setSize({ 20, 300 });

		位置.x -= 25;
	}
}

static void on_信息条变换(C_Widget* self) {
	C_信息条* box = static_cast<C_信息条*>(self);

	auto e = self->f_get更新组件();
	uint32 最近文件数量 = e.m_Num - 4;

	box->m_背景绘制.f_alloc(1);
	box->m_画心绘制.f_alloc(1);


	mat3X2 mat;
	mat.row0 = {};
	mat.row1 = self->m_Size;
	mat.row2 = { 6, 0 };

	mat.row1.y -= 25;
	box->m_背景绘制.f_set单色填充(0, mat, S_RGBA8UI{ 130, 130, 120, 255 }, S_Widget预设凸包图元::m_矩形);
	
}

C_信息条::C_信息条(S_UI渲染环境& ctx) : C_Widget(&ctx){
	
}

C_信息条::~C_信息条() {
	
}








